﻿@using WD.Web.MVC.Common
@model IEnumerable<WD.Db.Contract.Rbac_FunctionModel>

@{
    ViewBag.Title = "WD.Db.Contract.Model.Rbac_FunctionModel_Index";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
    var i = 0;
}

@section Script
{
    <script>
        var id = "Rbac_FunctionModel";
        var title = "新增功能模块";
        //新增按钮配置信息（弹框）
        var option_add = {
            id: id,
            title: title,
            yesfn: function () {
                //AJAX加载过渡动画
                DialogLoading({ id: id }, true);
                //TODO AJAX保存事件开始

                $("#Rbac_FunctionModel_mainForm").PostForm({
                    vfn: Rbac_FunctionModelCheckField,
                    success: function (data) {
                        msgsuc(data);
                        SearchTab();
                        CloseDialog(id);
                    },
                    error: function (data) {
                        msgerr(data);
                    },
                    complete: DialogLoading({ id: id }, false)
                });

                //隐藏AJAX加载过渡动画
                DialogLoading({ id: id }, false);
                //关闭窗口
                CloseDialog(id);

                //TODO AJAX保存事件结束
            },
            yestxt: "保存"
        };

        $('#ModelLevel').select2();
        $('#ModelType').select2();
    </script>

}

@section ToolbarArea{
    <a href="@Url.Action("Create")" target="edit" data-option='option_add'  class="btn pull-left">
        <i class="fa fa-plus"></i>新增
    </a>
}


@section SearchArea{
    <div class="form-group pull-left form-group-select2">
        @Html.DropDownList("ModelLevel", "请选择功能级别")
    </div>
    <div class="form-group pull-left form-group-select2">
        @Html.DropDownList("ModelType", "请选择功能类型")
    </div>
}

@section MainTable{
    <table class="table">
        <thead>
            <tr>
                <th class="text-left"><span>序号</span></th>
                <th><a href="#" role="sort" data-field="ModelName"><span>功能名字</span></a></th>
                <th><a href="#" role="sort" data-field="Url"><span>连接地址</span></a></th>
                <th><a href="#" role="sort" data-field="EditDate"><span>编辑时间</span></a></th>
                <th><a href="#" role="sort" data-field="EditUser"><span>编辑人</span></a></th>
                <th><a href="#" role="sort" data-field="Sort"><span>排序</span></a></th>
                <th><a href="#" role="sort" data-field="ModelLevel"><span>模版级别</span></a></th>
                <th><a href="#" role="sort" data-field="ModelType"><span>模版类型</span></a></th>
                <th><a href="#" role="sort" data-field="ModelCode"><span>权限全称连接</span></a></th>
                <th class="text-right"><span>操作</span></th>


            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                i++;
                <tr>
                    <td>
                        @i
                    </td>
                    <td>
                        <i class="fa @item.Icon"></i>&nbsp;@Html.DisplayFor(modelItem => item.ModelName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Url)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.EditDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.EditUser)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Sort)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => CommonCache.CodeDataByCache[item.ModelLevel].CodeName)
                    </td>
                    <td>
                        @try 
	{	        
		@Html.DisplayFor(modelItem => CommonCache.CodeDataByCache[item.ModelType].CodeName)
	}
	catch (Exception)
	{
		
	}
                        
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ModelCode)
                    </td>
                    <td class="text-right">
                        <a href="@Url.Action("Edit", new { id = item.ID })" class="table-link" target="edit" data-option='option_add' >
                            <span class="fa-stack">
                                <i class="fa fa-square fa-stack-2x"></i>
                                <i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                        <a href="@Url.Action("Deleted", new { ids = item.ID })" class="table-link danger" target="ajax" data-reload="true">
                            <span class="fa-stack">
                                <i class="fa fa-square fa-stack-2x"></i>
                                <i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
}


